#include <iostream>
#include <string>
using namespace std;



int main(){
	int n,c,t=0,l,tf;
	cin>>n;
	int li[n]; 
	
	for(int i=0;i<n;i++){
	  cin>>li[i];
	}
	
	for(int i=1;i<1000000;i++){
		while(1){
			c = 0;
			l = 0;
			for(int j=0;j<n;j++){
				if(li[j] == i+l){
					c = 1;
					li[j] = 0;
					//cout<<"li["<<j<<"] is killed by "<<i<<" when t="<<t<<endl; 
					l++;
				}
			}
			if(c == 0){
				break;
			}
			else{
				t++;
			}
		}
		tf = 1;
		for(int i=0;i<n;i++){
			if(li[i] != 0){
				tf = 0;
				break;
			}
		}
		if(tf == 1){
			break;
		}
	}
	
	cout<<t;
	
	return 0;
} 